package com.rainman.simpleredis.core.utils;

import java.util.Arrays;

public class DelayList {


    private final String[] delayList=new String[10];

    private int delayIndex=0;

    public void add(String key){

        delayList[delayIndex%10]=key;
        delayIndex++;
        if(delayIndex>100000){
            delayIndex=delayIndex-100000;
        }
    }

    public void remove(String key){
        for(int i=0;i<delayList.length;i++){
            if(key.equals(delayList[i])){
                delayList[i]="";
                return;
            }

        }
    }

    public boolean hasKey(String key){
        if(key==null){
            return false;
        }

        return Arrays.asList(delayList).contains(key);

    }


}
